package com.tongqin.distributed;// $Id$

import java.nio.*;

public class UseFloatBuffer {

    static public void main(String args[]) throws Exception {
        //分配空间
        FloatBuffer buffer = FloatBuffer.allocate(10);

//        根据capacity容器的大小，进行设置
        for (int i = 0; i < buffer.capacity(); ++i) {
            float f = (float) Math.sin((((float) i) / 10) * (2 * Math.PI));
            buffer.put(f);
        }

        buffer.flip();

        //while和map的迭代器一样，有没有下一个值
        while (buffer.hasRemaining()) {
            float f = buffer.get();
            System.out.println(f);
        }
    }
}
